﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;

namespace Brc_PaaS.Dal
{
    public interface IRepository<T> where T : class, new()
    {
        /// <summary>
        /// 根据条件获取单挑数据
        /// </summary>
        /// <param name="WhereLambda"></param>
        /// <returns></returns>
        T Get(Expression<Func<T, bool>> WhereLambda);
        /// <summary>
        /// 根据条件获取列表数据
        /// </summary>
        /// <param name="WhereLambda"></param>
        /// <returns></returns>
        List<T> GetList(Expression<Func<T, bool>> WhereLambda);
        /// <summary>
        /// 根据条件分页获取数据
        /// </summary>
        /// <param name="WhereLambda"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        List<T> GetPageList(Expression<Func<T, bool>> WhereLambda, int pageIndex, int pageSize, out int total);
        /// <summary>
        /// 新增数据，并返回新增的数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        int AddItem(T model);

        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        int AddList(List<T> list);
        /// <summary>
        /// 根据条件删除数据
        /// </summary>
        /// <param name="WhereLambda"></param>
        /// <returns></returns>
        int Delete(Expression<Func<T, bool>> WhereLambda);
        /// <summary>
        /// 根据Id集合删除数据
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        int Delete(dynamic[] ids);
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        int Update(T model);
        /// <summary>
        /// 批量更新数据
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        int Update(List<T> list);

        /// <summary>
        /// 判断是否存在满足条件的数据
        /// </summary>
        /// <param name="WhereLambda"></param>
        /// <returns></returns>
        bool Exist(Expression<Func<T, bool>> WhereLambda);
        
    }
}
